package com.hhsjtest.bus_advert.viewholder

import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import com.hhsjdesign.dynamicui.annoprocess.ABusinessViewHolder
import com.hhsjdesign.dynamicui.businessdata.IViewable
import com.hhsjdesign.dynamicui.utils.BusinessViewCreator
import com.hhsjdesign.dynamicui.core.property.viewdata.ItemViewData
import com.hhsjtest.bus_advert.businessdata.Advert


/**
 * 广告
 */
@ABusinessViewHolder("advert")
class AdvertViewHolder(itemWidgetType: String) : BusinessViewCreator<Advert>(itemWidgetType) {

    override fun transform(origin: Advert): IViewable<Advert> {
        return origin.toViewable()
    }

    override fun startActivity(context: Context, businessItemData: Advert?) {
        Toast.makeText(context, businessItemData!!.title, Toast.LENGTH_SHORT).show()
    }

    override fun bindDataAndEvent(
        view: View,
        viewable: IViewable<*>?,
        itemWidgetType: String?,
        businessType: String?,
        itemWidget: ItemViewData?
    ) {
    }

    override fun bindDataWithoutEvent(
        view: View,
        viewable: IViewable<*>?,
        itemWidgetType: String?,
        businessType: String?,
        itemWidget: ItemViewData?
    ) {
    }

    override fun createViewXml(
        context: Context,
        itemWidgetType: String?,
        businessType: String?,
        parent: ViewGroup
    ): View {
        return View(context)
    }
}